<?php
class addAction extends rareAction{
	public function execute(){}
	public function executePost(){
		$product = $this->getPostParam('p',array());
		$images = $this->getPostParam('img',array());
		$keyword = $this->getPostParam('keyword','');
		if(empty($product)) jsonReturn(0,'添加失败');
		$productDao = new DaoProduct();
		//标签
		if($keyword!=''){
			$keywordID = service_keyword::save($keyword);
			$product['keyword'] = $keywordID;
		}
		$now = date("Y-m-d H:i:s");
		$product['createTime'] = $product['updateTime'] = $now;
		$id = $productDao->insert($product);
		if(!empty($images)){
			service_image::insert($images,service_type::PRODUCT,$id);
		}
		if($id) jsonReturn(1,'ok');
		jsonReturn(0,'fail');
	}
}
?>
